import 'package:flutter/material.dart';
import 'animated_background.dart';

class PageContainer extends StatelessWidget {
  final String title;
  final List<Widget>? actions;
  final Widget body;
  final Widget? floatingActionButton;
  final bool useAnimatedBackground;

  const PageContainer({
    Key? key,
    required this.title,
    this.actions,
    required this.body,
    this.floatingActionButton,
    this.useAnimatedBackground = true,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final content = Scaffold(
      appBar: AppBar(
        title: Text(title),
        elevation: 0,
        actions: actions,
        shape: const RoundedRectangleBorder(
          borderRadius: BorderRadius.vertical(
            bottom: Radius.circular(16),
          ),
        ),
      ),
      body: body,
      floatingActionButton: floatingActionButton,
    );

    return useAnimatedBackground
        ? AnimatedBackground(child: content)
        : content;
  }
}

